How to control the display order of stacking and legends and add display of total information on the tooltip
Problem Description

For the stacked area chart, I want to control the order of stacking. For example, I want the area chart to be stacked in the order of "China", "USA", "EU", "Africa" from bottom to top, and then the display order of the legend also follows " China", "USA", "EU", "Africa" are displayed in order from left to right, and when hovering up, the tooltip can display the total information, as shown in the following figure:

solution
This can be configured very simply on VChart, which only requires two steps:
- Control the stacking order by configuring
domainandsortIndexfor the grouping field on thedata.fieldspropertydomainto declare the ordersortIndexdeclared as 0 means sorting indomainorder

Because the order of the legend is displayed in the order of field domain declaration by default, the legend does not need to be configured here.
- By configuring
updateContentfortooltip.dimension, you can dynamically add the required information to the tooltip content, and you can also get all the information displayed by the current tooltip.

Code Example
Result display
Online effect reference: https://codepen.io/Sima/pen/WNLxdyg
Related documents
Stacked area chart demo: https://www.visactor.io/vchart/demo/area-chart/stacked-area
Area chart tutorial: https://www.visactor.io/vchart/guide/tutorial_docs/Chart_Types/Area
Data configuration tutorial: https://www.visactor.io/vchart/guide/tutorial_docs/Chart_Concepts/Data/Data_Types_and_Interface
Tooltip configuration tutorial: https://www.visactor.io/vchart/guide/tutorial_docs/Chart_Concepts/Tooltip
Data field configuration: https://www.visactor.io/vchart/option/areaChart#data(IDataType%7CIDataType%5B%5D).IDataValues.fields
Tooltip configuration item: https://www.visactor.io/vchart/option/areaChart#tooltip.visible